import React, { useMemo, useState } from 'react';
import VideoJS from '@/components/VideoJs';

export default function (props: any) {
  const { playObj } = props;
  const [url, setUrl] = useState('');
  const videoJsOptions = {
    autoplay: true,
    controls: true,
    responsive: true,
    fluid: true,
    // width: 865,
    // height: 470,
    sources: [
      {
        src: url,
        type: 'application/x-mpegURL',
      },
    ],
  };
  useMemo(() => {
    setUrl(playObj.m3u8Url);
  }, [playObj.m3u8Url]);

  return (
    <>
      <VideoJS options={videoJsOptions} />
    </>
  );
}
